package com;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-10-27
 * Time: 18:05
 */
@Component
public class UserBeans {
    //方法注入对象  改变bean对象的生命周期为多例对象
    @Scope("prototype")
    @Bean //这里默认是singleton单例的
    public User user() {
        User user = new User();
        user.setId(101);
        user.setAge(20);
        user.setName("张三");
        return user;
    }
}
